////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  asdtuning.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "asdtuning.h"
#include "parametersetmanager.h"

ASDTUNING_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ChromatixASDTuningTypeClass::ChromatixASDTuningTypeClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(ASD_Software_Type);
    PARAMETER_INITIALIZE(snow_scene_detect);
    PARAMETER_INITIALIZE(backlit_scene_detect);
    PARAMETER_INITIALIZE(landscape_scene_detect);
    PARAMETER_INITIALIZE(portrait_scene_detect);
    PARAMETER_INITIALIZE(auto_hdr_detect);
    PARAMETER_INITIALIZE(hazy_scene_detect);
    PARAMETER_INITIALIZE(gamma_table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ChromatixASDTuningTypeClass::ChromatixASDTuningTypeClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(ASD_Software_Type);
    PARAMETER_INITIALIZE(snow_scene_detect);
    PARAMETER_INITIALIZE(backlit_scene_detect);
    PARAMETER_INITIALIZE(landscape_scene_detect);
    PARAMETER_INITIALIZE(portrait_scene_detect);
    PARAMETER_INITIALIZE(auto_hdr_detect);
    PARAMETER_INITIALIZE(hazy_scene_detect);
    PARAMETER_INITIALIZE(gamma_table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ChromatixASDTuningTypeClass::~ChromatixASDTuningTypeClass()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* ChromatixASDTuningTypeClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "ChromatixASDTuningData")) == 0)
    {
        name = "ChromatixASDTuningData";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load asd_gamma_table_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadasd_gamma_table_type(
    ParameterFileSymbolTableEntry* entry,
    asd_gamma_table_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadUInt16(&structure->bits_depth);
    result = result && entry->ReadUInt16(&structure->entries_num);
    for (UINT32 i = 0; result && i < 256; i++)
    {
        result = result && entry->ReadUInt16(&structure->gamma_G[i]);
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load hazy_scene_detect_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadhazy_scene_detect_type(
    ParameterFileSymbolTableEntry* entry,
    hazy_scene_detect_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->hazy_detection_enable);
    result = result && entry->ReadFloat(&structure->hazy_running_frequency);
    result = result && entry->ReadFloat(&structure->hazy_detection_threshold_on);
    result = result && entry->ReadFloat(&structure->hazy_detection_threshold_off);
    result = result && entry->ReadUInt16(&structure->ui_hazy_display_th);
    result = result && entry->ReadInt32(&structure->hazy_3A_compensation_enable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load auto_hdr_detect_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadauto_hdr_detect_type(
    ParameterFileSymbolTableEntry* entry,
    auto_hdr_detect_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->backlight_high_threshold);
    result = result && entry->ReadFloat(&structure->backlight_low_threshold);
    result = result && entry->ReadFloat(&structure->portrait_high_threshold);
    result = result && entry->ReadFloat(&structure->portrait_low_threshold);
    result = result && entry->ReadInt32(&structure->auto_hdr_3A_compensation_enable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load portrait_scene_detect_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadportrait_scene_detect_type(
    ParameterFileSymbolTableEntry* entry,
    portrait_scene_detect_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->portrait_detection_enable);
    result = result && entry->ReadFloat(&structure->skin_color_boost_factor);
    result = result && entry->ReadFloat(&structure->min_face_content_threshold);
    result = result && entry->ReadFloat(&structure->max_face_content_threshold);
    result = result && entry->ReadFloat(&structure->soft_focus_degree_7_7);
    result = result && entry->ReadFloat(&structure->soft_focus_degree_5_5);
    result = result && entry->ReadFloat(&structure->aggressiveness);
    result = result && entry->ReadUInt16(&structure->ui_portrait_display_th);
    result = result && entry->ReadInt32(&structure->portrait_3A_compensation_enable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load landscape_scene_detect_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadlandscape_scene_detect_type(
    ParameterFileSymbolTableEntry* entry,
    landscape_scene_detect_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->landscape_detection_enable);
    result = result && entry->ReadFloat(&structure->landscape_red_boost_factor);
    result = result && entry->ReadFloat(&structure->landscape_green_boost_factor);
    result = result && entry->ReadFloat(&structure->landscape_blue_boost_factor);
    result = result && entry->ReadFloat(&structure->min_blue_green_content_detection_threshold);
    result = result && entry->ReadFloat(&structure->max_blue_green_content_detection_threshold);
    result = result && entry->ReadInt32(&structure->green_offset_rg);
    result = result && entry->ReadInt32(&structure->green_offset_bg);
    result = result && entry->ReadFloat(&structure->aggressiveness);
    result = result && entry->ReadInt64(&structure->lux_idx_indoor);
    result = result && entry->ReadInt64(&structure->lux_idx_outdoor);
    result = result && entry->ReadUInt16(&structure->ui_landscape_display_th);
    result = result && entry->ReadInt32(&structure->landscape_3A_compensation_enable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load backlit_scene_detect_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadbacklit_scene_detect_type(
    ParameterFileSymbolTableEntry* entry,
    backlit_scene_detect_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->backlight_detection_enable);
    result = result && entry->ReadFloat(&structure->histogram_offset);
    result = result && entry->ReadUInt64(&structure->low_luma_threshold);
    result = result && entry->ReadUInt64(&structure->high_luma_threshold);
    result = result && entry->ReadFloat(&structure->low_luma_count_percent_threshold);
    result = result && entry->ReadFloat(&structure->high_luma_count_percent_threshold);
    result = result && entry->ReadFloat(&structure->kept_pixel_ratio_th);
    result = result && entry->ReadFloat(&structure->backlit_aggressiveness);
    result = result && entry->ReadFloat(&structure->max_percent_threshold);
    result = result && entry->ReadUInt16(&structure->ui_backlit_display_th);
    result = result && entry->ReadInt32(&structure->backlit_3A_compensation_enable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load snow_scene_detect_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadsnow_scene_detect_type(
    ParameterFileSymbolTableEntry* entry,
    snow_scene_detect_type* structure)
{
    BOOL result = TRUE;
    structure->snow_scene_detection_enable = (asd_chrx_flag_t)entry->ReadEnum(&result);
    result = result && entry->ReadUInt64(&structure->y_cloudy_snow_threshold);
    result = result && entry->ReadUInt64(&structure->awb_y_max_in_grey);
    result = result && entry->ReadUInt64(&structure->min_snow_cloudy_sample_th);
    result = result && entry->ReadUInt64(&structure->extreme_snow_cloudy_sample_th);
    result = result && entry->ReadUInt32(&structure->snow_scene_indoor_index);
    result = result && entry->ReadUInt32(&structure->snow_scene_outdoor_index);
    result = result && entry->ReadUInt64(&structure->severe_snow_scene_cap);
    result = result && entry->ReadFloat(&structure->snowscene_aggressiveness);
    result = result && entry->ReadUInt16(&structure->ui_snow_cloudy_display_th);
    result = result && entry->ReadInt32(&structure->snow_scene_3A_compensation_enable);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load ChromatixASDTuningType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::LoadChromatixASDTuningType(
    ParameterFileSymbolTableEntry* entry,
    ChromatixASDTuningType* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && entry->ReadInt32(&structure->ASD_Software_Type);
    result = result && Loadsnow_scene_detect_type(entry, &structure->snow_scene_detect);
    result = result && Loadbacklit_scene_detect_type(entry, &structure->backlit_scene_detect);
    result = result && Loadlandscape_scene_detect_type(entry, &structure->landscape_scene_detect);
    result = result && Loadportrait_scene_detect_type(entry, &structure->portrait_scene_detect);
    result = result && Loadauto_hdr_detect_type(entry, &structure->auto_hdr_detect);
    result = result && Loadhazy_scene_detect_type(entry, &structure->hazy_scene_detect);
    result = result && Loadasd_gamma_table_type(entry, &structure->gamma_table);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ChromatixASDTuningTypeClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    ChromatixASDTuningType::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);
    result = result && entry->ReadInt32(&structure->incr_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* ChromatixASDTuningTypeClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    ChromatixASDTuningTypeClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW ChromatixASDTuningTypeClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadChromatixASDTuningType(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


ASDTUNING_NAMESPACE_END
